package com.shujia.day11;

/*
    统计大串中小串出现的次数（作业）
    举例：在字符串” woaijavawozhenaijavawozhendeaijavawozhendehenaijavaxinbuxinwoaijavagun”中java出现了5次

 */
public class StringTest2 {
    public static void main(String[] args) {
        String bigStr = "woaijavawozhenaijavawozhendeaijavawozhendehenaijavaxinbuxinwoaijavagun";

        int counts = 0;

        String smallStr = "java";

        while (bigStr.contains(smallStr)){ // 4 8
            counts++;
            bigStr = bigStr.substring(bigStr.indexOf(smallStr)+smallStr.length());
        }


        System.out.println("共计找小字符串 "+smallStr+" 出现 "+counts+"次");
    }
}
